package com.eostoken.eos_wallet.mvp.presenter;

import android.app.Activity;
import android.content.Context;

import com.eostoken.eos_wallet.eosnet.callback.CheckDataTaskCallback;
import com.eostoken.eos_wallet.mvp.callback.CommonCallback;
import com.eostoken.eos_wallet.mvp.mode.TransactionModel;
import com.eostoken.eos_wallet.mvp.view.TransactionView;
import com.fredy.mvp.BasePresenter;

import java.util.Map;

public class TransactionPresenterImpl extends BasePresenter<TransactionModel, TransactionView>
        implements TransactionPresenter, CommonCallback, CheckDataTaskCallback {

    private Activity context;

    public TransactionPresenterImpl(Activity context) {
        super(context);
        this.context = context;
    }

    @Override
    protected void onViewDestroy() {

    }

    @Override
    public void onSuccess(Object data, String successMsg, int responseSuccessCode) {
        if (getView() != null)
            getView().updateView(true, data, responseSuccessCode);
    }

    @Override
    public void onFailure(String msg, int responseFailCode) {
        if (getView() != null)
            getView().updateView(false, msg, responseFailCode);
    }

    @Override
    public void getData(boolean isRefresh) {

    }

    @Override
    public void getMoreData() {

    }

    @Override
    public void sendTransaction(String name, String privateKey, String fromAccount, String account, String jsonData) {
        model.buyramRaw(name, privateKey, fromAccount, account, jsonData, this);
    }

    @Override
    public void requestAccountInfo(Map<String, Object> accountName) {
        model.getAccount(context, accountName, true, this);
    }

    @Override
    public void requestgetTableRows(Map<String, Object> accountName) {
        model.getTableRows(context, accountName, true, this);
    }

    @Override
    public void update(Object object) {
//        getView().updateView(false, object, null);
    }

    @Override
    public void finish(boolean success, Object o1, Object o2) {
        if (getView() != null)
            getView().updateView(success, o1, o2);
    }
}
